\(\int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx\) [68]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [F(-1)]
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 36, antiderivative size = 143 \[ \int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx=\frac {\sqrt {2} \sqrt {a} (i A+B) \text {arctanh}\left (\frac {\sqrt {a+i a \tan (c+d x)}}{\sqrt {2} \sqrt {a}}\right )}{d}-\frac {8 B \sqrt {a+i a \tan (c+d x)}}{5 d}+\frac {2 B \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)}}{5 d}-\frac {2 (5 i A+B) (a+i a \tan (c+d x))^{3/2}}{15 a d} \]

[Out]

(I*A+B)*arctanh(1/2*(a+I*a*tan(d*x+c))^(1/2)*2^(1/2)/a^(1/2))*2^(1/2)*a^(1/2)/d-8/5*B*(a+I*a*tan(d*x+c))^(1/2)
/d+2/5*B*(a+I*a*tan(d*x+c))^(1/2)*tan(d*x+c)^2/d-2/15*(5*I*A+B)*(a+I*a*tan(d*x+c))^(3/2)/a/d

Rubi [A] (verified)

Time = 0.35 (sec) , antiderivative size = 143, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.139, Rules used = {3678, 3673, 3608, 3561, 212} \[ \int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx=\frac {\sqrt {2} \sqrt {a} (B+i A) \text {arctanh}\left (\frac {\sqrt {a+i a \tan (c+d x)}}{\sqrt {2} \sqrt {a}}\right )}{d}-\frac {2 (B+5 i A) (a+i a \tan (c+d x))^{3/2}}{15 a d}+\frac {2 B \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)}}{5 d}-\frac {8 B \sqrt {a+i a \tan (c+d x)}}{5 d} \]

[In]

Int[Tan[c + d*x]^2*Sqrt[a + I*a*Tan[c + d*x]]*(A + B*Tan[c + d*x]),x]

[Out]

(Sqrt[2]*Sqrt[a]*(I*A + B)*ArcTanh[Sqrt[a + I*a*Tan[c + d*x]]/(Sqrt[2]*Sqrt[a])])/d - (8*B*Sqrt[a + I*a*Tan[c
+ d*x]])/(5*d) + (2*B*Tan[c + d*x]^2*Sqrt[a + I*a*Tan[c + d*x]])/(5*d) - (2*((5*I)*A + B)*(a + I*a*Tan[c + d*x
])^(3/2))/(15*a*d)

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 3561

Int[Sqrt[(a_) + (b_.)*tan[(c_.) + (d_.)*(x_)]], x_Symbol] :> Dist[-2*(b/d), Subst[Int[1/(2*a - x^2), x], x, Sq
rt[a + b*Tan[c + d*x]]], x] /; FreeQ[{a, b, c, d}, x] && EqQ[a^2 + b^2, 0]

Rule 3608

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*(
(a + b*Tan[e + f*x])^m/(f*m)), x] + Dist[(b*c + a*d)/b, Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[{a, b, c,
d, e, f, m}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] &&  !LtQ[m, 0]

Rule 3673

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(
e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[B*d*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e
 + f*x])^m*Simp[A*c - B*d + (B*c + A*d)*Tan[e + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, m}, x] && NeQ[b
*c - a*d, 0] &&  !LeQ[m, -1]

Rule 3678

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[B*(a + b*Tan[e + f*x])^m*((c + d*Tan[e + f*x])^n/(f*(m + n))), x] +
Dist[1/(a*(m + n)), Int[(a + b*Tan[e + f*x])^m*(c + d*Tan[e + f*x])^(n - 1)*Simp[a*A*c*(m + n) - B*(b*c*m + a*
d*n) + (a*A*d*(m + n) - B*(b*d*m - a*c*n))*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, m}, x] &
& NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && GtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {2 B \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)}}{5 d}+\frac {2 \int \tan (c+d x) \sqrt {a+i a \tan (c+d x)} \left (-2 a B+\frac {1}{2} a (5 A-i B) \tan (c+d x)\right ) \, dx}{5 a} \\ & = \frac {2 B \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)}}{5 d}-\frac {2 (5 i A+B) (a+i a \tan (c+d x))^{3/2}}{15 a d}+\frac {2 \int \sqrt {a+i a \tan (c+d x)} \left (-\frac {1}{2} a (5 A-i B)-2 a B \tan (c+d x)\right ) \, dx}{5 a} \\ & = -\frac {8 B \sqrt {a+i a \tan (c+d x)}}{5 d}+\frac {2 B \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)}}{5 d}-\frac {2 (5 i A+B) (a+i a \tan (c+d x))^{3/2}}{15 a d}+(-A+i B) \int \sqrt {a+i a \tan (c+d x)} \, dx \\ & = -\frac {8 B \sqrt {a+i a \tan (c+d x)}}{5 d}+\frac {2 B \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)}}{5 d}-\frac {2 (5 i A+B) (a+i a \tan (c+d x))^{3/2}}{15 a d}+\frac {(2 a (i A+B)) \text {Subst}\left (\int \frac {1}{2 a-x^2} \, dx,x,\sqrt {a+i a \tan (c+d x)}\right )}{d} \\ & = \frac {\sqrt {2} \sqrt {a} (i A+B) \text {arctanh}\left (\frac {\sqrt {a+i a \tan (c+d x)}}{\sqrt {2} \sqrt {a}}\right )}{d}-\frac {8 B \sqrt {a+i a \tan (c+d x)}}{5 d}+\frac {2 B \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)}}{5 d}-\frac {2 (5 i A+B) (a+i a \tan (c+d x))^{3/2}}{15 a d} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.28 (sec) , antiderivative size = 111, normalized size of antiderivative = 0.78 \[ \int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx=\frac {15 \sqrt {2} \sqrt {a} (i A+B) \text {arctanh}\left (\frac {\sqrt {a+i a \tan (c+d x)}}{\sqrt {2} \sqrt {a}}\right )+2 \sqrt {a+i a \tan (c+d x)} \left (-5 i A-13 B+(5 A-i B) \tan (c+d x)+3 B \tan ^2(c+d x)\right )}{15 d} \]

[In]

Integrate[Tan[c + d*x]^2*Sqrt[a + I*a*Tan[c + d*x]]*(A + B*Tan[c + d*x]),x]

[Out]

(15*Sqrt[2]*Sqrt[a]*(I*A + B)*ArcTanh[Sqrt[a + I*a*Tan[c + d*x]]/(Sqrt[2]*Sqrt[a])] + 2*Sqrt[a + I*a*Tan[c + d
*x]]*((-5*I)*A - 13*B + (5*A - I*B)*Tan[c + d*x] + 3*B*Tan[c + d*x]^2))/(15*d)

Maple [A] (verified)

Time = 0.18 (sec) , antiderivative size = 124, normalized size of antiderivative = 0.87

method result size
derivativedivides \(\frac {2 i \left (\frac {i B \left (a +i a \tan \left (d x +c \right )\right )^{\frac {5}{2}}}{5}-\frac {i B a \left (a +i a \tan \left (d x +c \right )\right )^{\frac {3}{2}}}{3}-\frac {A a \left (a +i a \tan \left (d x +c \right )\right )^{\frac {3}{2}}}{3}+i a^{2} B \sqrt {a +i a \tan \left (d x +c \right )}+\frac {a^{\frac {5}{2}} \left (-i B +A \right ) \sqrt {2}\, \operatorname {arctanh}\left (\frac {\sqrt {a +i a \tan \left (d x +c \right )}\, \sqrt {2}}{2 \sqrt {a}}\right )}{2}\right )}{d \,a^{2}}\) \(124\)
default \(\frac {2 i \left (\frac {i B \left (a +i a \tan \left (d x +c \right )\right )^{\frac {5}{2}}}{5}-\frac {i B a \left (a +i a \tan \left (d x +c \right )\right )^{\frac {3}{2}}}{3}-\frac {A a \left (a +i a \tan \left (d x +c \right )\right )^{\frac {3}{2}}}{3}+i a^{2} B \sqrt {a +i a \tan \left (d x +c \right )}+\frac {a^{\frac {5}{2}} \left (-i B +A \right ) \sqrt {2}\, \operatorname {arctanh}\left (\frac {\sqrt {a +i a \tan \left (d x +c \right )}\, \sqrt {2}}{2 \sqrt {a}}\right )}{2}\right )}{d \,a^{2}}\) \(124\)
parts \(\frac {2 i A \left (-\frac {\left (a +i a \tan \left (d x +c \right )\right )^{\frac {3}{2}}}{3}+\frac {a^{\frac {3}{2}} \sqrt {2}\, \operatorname {arctanh}\left (\frac {\sqrt {a +i a \tan \left (d x +c \right )}\, \sqrt {2}}{2 \sqrt {a}}\right )}{2}\right )}{d a}+\frac {2 B \left (-\frac {\left (a +i a \tan \left (d x +c \right )\right )^{\frac {5}{2}}}{5}+\frac {a \left (a +i a \tan \left (d x +c \right )\right )^{\frac {3}{2}}}{3}-a^{2} \sqrt {a +i a \tan \left (d x +c \right )}+\frac {a^{\frac {5}{2}} \sqrt {2}\, \operatorname {arctanh}\left (\frac {\sqrt {a +i a \tan \left (d x +c \right )}\, \sqrt {2}}{2 \sqrt {a}}\right )}{2}\right )}{d \,a^{2}}\) \(153\)

[In]

int((a+I*a*tan(d*x+c))^(1/2)*tan(d*x+c)^2*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

2*I/d/a^2*(1/5*I*B*(a+I*a*tan(d*x+c))^(5/2)-1/3*I*B*a*(a+I*a*tan(d*x+c))^(3/2)-1/3*A*a*(a+I*a*tan(d*x+c))^(3/2
)+I*a^2*B*(a+I*a*tan(d*x+c))^(1/2)+1/2*a^(5/2)*(A-I*B)*2^(1/2)*arctanh(1/2*(a+I*a*tan(d*x+c))^(1/2)*2^(1/2)/a^
(1/2)))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 383 vs. \(2 (112) = 224\).

Time = 0.26 (sec) , antiderivative size = 383, normalized size of antiderivative = 2.68 \[ \int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx=-\frac {15 \, \sqrt {2} {\left (d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )} \sqrt {-\frac {{\left (A^{2} - 2 i \, A B - B^{2}\right )} a}{d^{2}}} \log \left (-\frac {4 \, {\left ({\left (-i \, A - B\right )} a e^{\left (i \, d x + i \, c\right )} + {\left (d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )} \sqrt {-\frac {{\left (A^{2} - 2 i \, A B - B^{2}\right )} a}{d^{2}}} \sqrt {\frac {a}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}}\right )} e^{\left (-i \, d x - i \, c\right )}}{i \, A + B}\right ) - 15 \, \sqrt {2} {\left (d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )} \sqrt {-\frac {{\left (A^{2} - 2 i \, A B - B^{2}\right )} a}{d^{2}}} \log \left (-\frac {4 \, {\left ({\left (-i \, A - B\right )} a e^{\left (i \, d x + i \, c\right )} - {\left (d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )} \sqrt {-\frac {{\left (A^{2} - 2 i \, A B - B^{2}\right )} a}{d^{2}}} \sqrt {\frac {a}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}}\right )} e^{\left (-i \, d x - i \, c\right )}}{i \, A + B}\right ) + 4 \, \sqrt {2} {\left ({\left (10 i \, A + 17 \, B\right )} e^{\left (5 i \, d x + 5 i \, c\right )} + 10 \, {\left (i \, A + 2 \, B\right )} e^{\left (3 i \, d x + 3 i \, c\right )} + 15 \, B e^{\left (i \, d x + i \, c\right )}\right )} \sqrt {\frac {a}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}}}{30 \, {\left (d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \]

[In]

integrate((a+I*a*tan(d*x+c))^(1/2)*tan(d*x+c)^2*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

-1/30*(15*sqrt(2)*(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I*c) + d)*sqrt(-(A^2 - 2*I*A*B - B^2)*a/d^2)*log
(-4*((-I*A - B)*a*e^(I*d*x + I*c) + (d*e^(2*I*d*x + 2*I*c) + d)*sqrt(-(A^2 - 2*I*A*B - B^2)*a/d^2)*sqrt(a/(e^(
2*I*d*x + 2*I*c) + 1)))*e^(-I*d*x - I*c)/(I*A + B)) - 15*sqrt(2)*(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I
*c) + d)*sqrt(-(A^2 - 2*I*A*B - B^2)*a/d^2)*log(-4*((-I*A - B)*a*e^(I*d*x + I*c) - (d*e^(2*I*d*x + 2*I*c) + d)
*sqrt(-(A^2 - 2*I*A*B - B^2)*a/d^2)*sqrt(a/(e^(2*I*d*x + 2*I*c) + 1)))*e^(-I*d*x - I*c)/(I*A + B)) + 4*sqrt(2)
*((10*I*A + 17*B)*e^(5*I*d*x + 5*I*c) + 10*(I*A + 2*B)*e^(3*I*d*x + 3*I*c) + 15*B*e^(I*d*x + I*c))*sqrt(a/(e^(
2*I*d*x + 2*I*c) + 1)))/(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I*c) + d)

Sympy [F]

\[ \int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx=\int \sqrt {i a \left (\tan {\left (c + d x \right )} - i\right )} \left (A + B \tan {\left (c + d x \right )}\right ) \tan ^{2}{\left (c + d x \right )}\, dx \]

[In]

integrate((a+I*a*tan(d*x+c))**(1/2)*tan(d*x+c)**2*(A+B*tan(d*x+c)),x)

[Out]

Integral(sqrt(I*a*(tan(c + d*x) - I))*(A + B*tan(c + d*x))*tan(c + d*x)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 130, normalized size of antiderivative = 0.91 \[ \int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx=-\frac {i \, {\left (15 \, \sqrt {2} {\left (A - i \, B\right )} a^{\frac {7}{2}} \log \left (-\frac {\sqrt {2} \sqrt {a} - \sqrt {i \, a \tan \left (d x + c\right ) + a}}{\sqrt {2} \sqrt {a} + \sqrt {i \, a \tan \left (d x + c\right ) + a}}\right ) - 12 i \, {\left (i \, a \tan \left (d x + c\right ) + a\right )}^{\frac {5}{2}} B a + 20 \, {\left (i \, a \tan \left (d x + c\right ) + a\right )}^{\frac {3}{2}} {\left (A + i \, B\right )} a^{2} - 60 i \, \sqrt {i \, a \tan \left (d x + c\right ) + a} B a^{3}\right )}}{30 \, a^{3} d} \]

[In]

integrate((a+I*a*tan(d*x+c))^(1/2)*tan(d*x+c)^2*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

-1/30*I*(15*sqrt(2)*(A - I*B)*a^(7/2)*log(-(sqrt(2)*sqrt(a) - sqrt(I*a*tan(d*x + c) + a))/(sqrt(2)*sqrt(a) + s
qrt(I*a*tan(d*x + c) + a))) - 12*I*(I*a*tan(d*x + c) + a)^(5/2)*B*a + 20*(I*a*tan(d*x + c) + a)^(3/2)*(A + I*B
)*a^2 - 60*I*sqrt(I*a*tan(d*x + c) + a)*B*a^3)/(a^3*d)

Giac [F(-1)]

Timed out. \[ \int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx=\text {Timed out} \]

[In]

integrate((a+I*a*tan(d*x+c))^(1/2)*tan(d*x+c)^2*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

Timed out

Mupad [B] (verification not implemented)

Time = 8.28 (sec) , antiderivative size = 168, normalized size of antiderivative = 1.17 \[ \int \tan ^2(c+d x) \sqrt {a+i a \tan (c+d x)} (A+B \tan (c+d x)) \, dx=-\frac {2\,B\,\sqrt {a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}}{d}-\frac {A\,{\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^{3/2}\,2{}\mathrm {i}}{3\,a\,d}+\frac {2\,B\,{\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^{3/2}}{3\,a\,d}-\frac {2\,B\,{\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^{5/2}}{5\,a^2\,d}+\frac {\sqrt {2}\,A\,\sqrt {-a}\,\mathrm {atan}\left (\frac {\sqrt {2}\,\sqrt {a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}}{2\,\sqrt {-a}}\right )\,1{}\mathrm {i}}{d}-\frac {\sqrt {2}\,B\,\sqrt {a}\,\mathrm {atan}\left (\frac {\sqrt {2}\,\sqrt {a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}\,1{}\mathrm {i}}{2\,\sqrt {a}}\right )\,1{}\mathrm {i}}{d} \]

[In]

int(tan(c + d*x)^2*(A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i)^(1/2),x)

[Out]

(2*B*(a + a*tan(c + d*x)*1i)^(3/2))/(3*a*d) - (A*(a + a*tan(c + d*x)*1i)^(3/2)*2i)/(3*a*d) - (2*B*(a + a*tan(c
 + d*x)*1i)^(1/2))/d - (2*B*(a + a*tan(c + d*x)*1i)^(5/2))/(5*a^2*d) + (2^(1/2)*A*(-a)^(1/2)*atan((2^(1/2)*(a
+ a*tan(c + d*x)*1i)^(1/2))/(2*(-a)^(1/2)))*1i)/d - (2^(1/2)*B*a^(1/2)*atan((2^(1/2)*(a + a*tan(c + d*x)*1i)^(
1/2)*1i)/(2*a^(1/2)))*1i)/d